
// Copyright (C) Recursion Company. All rights reserved.

#ifndef __VOL_WTL_UI_MB_WND_H__
#define __VOL_WTL_UI_MB_WND_H__

#include <Imm.h>
#include "../../vMiniblink/lib/wke.h"
#include "../../vMiniblink/lib/RenderGDI.h"

typedef bool (WKE_CALL_TYPE *FN_wkeIsInitializes)();

class CVWnd_MBWnd : public CWindowImpl<CVWnd_MBWnd>
{
    BEGIN_DECLARE_VOL_NATIVE_WND_CLASS (CVWnd_MBWnd, IBaseEventListener, FALSE)
        if (CVolAppInstance::sIsVolPreFilterInputMessage (uMsg) == FALSE && webViewWndProc (hWnd, uMsg, wParam, lParam))
            return TRUE;
        MSG_WM_SIZE (OnSize)
        MSG_WM_PAINT (OnPaint)
        MSG_WM_DESTROY (OnDestroy)
        MSG_WM_SETCURSOR (OnSetCursor)
        MESSAGE_HANDLER (MWM_PRE_FILTER_INPUT_MSG, OnPreFilterInputMessage)
    END_DECLARE_VOL_NATIVE_WND_CLASS_NOT_CONTAINER ()

public:
    ~ CVWnd_MBWnd ();

protected:
    void OnSize (UINT nType, CSize size);
    void OnPaint (HDC hDCNotUsed);
    void OnDestroy ();
    BOOL OnSetCursor (CWindow wnd, UINT nHitTest, UINT message);
    LRESULT OnPreFilterInputMessage (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);

public:
    wkeWebView m_webView = NULL;
    CRenderGDI* m_render = NULL;
    int m_cursorInfoType = 0;

    static bool mbIsInit (const TCHAR* m_dllPath);
    static void mbInit (const TCHAR* m_dllPath);

    bool setCursorInfoType(HWND hWnd);
    bool webViewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
    void static WKE_CALL_TYPE onPaintUpdatedCallback(wkeWebView webView, void* param, const HDC hdc, int x, int y, int cx, int cy)
    {
        CVWnd_MBWnd* pThis= (CVWnd_MBWnd*)param;
        pThis->m_render->renderOnBlinkPaint( webView, hdc, x, y, cx, cy);
    }
};

#endif